package com.zc.tools.motionwelder;





import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.zc.tools.motionwelder.support.MSimpleAnimationPlayer;
import com.zc.tools.motionwelder.support.MSpriteData;
import com.zc.tools.motionwelder.support.MSpriteImageLoader;
import com.zc.tools.motionwelder.support.MSpriteLoader;

public class MotionWelderSupport {
	public static MSimpleAnimationPlayer makeMotionwelderAnimationPlayer(String fileName, TextureRegion[] regions,float initX,float initY)
	{
//		try {
//			MSpriteData mongoAnimationData = MSpriteLoader.loadMSprite(fileName, new C2dMSpriteImageLoader(regions));
//			final MSimpleAnimationPlayer player = new MSimpleAnimationPlayer(mongoAnimationData, (int)initX, (int)initY);
//			player.setAnimation(0);
//			
//			return player;
//		} catch (Exception e) {
//			Gdx.app.error("C2d", "Load Motionwelder file error :" + fileName);
//		}
		return null;
	}
	
	
	private static class C2dMSpriteImageLoader implements MSpriteImageLoader {
		private TextureRegion[] regions;

		public C2dMSpriteImageLoader(TextureRegion[] regions) {
			this.regions = regions;
		}

		@Override
		public TextureRegion[] loadImageClip(String spriteName, int imageId,
				int x, int y, int w, int h, int orientationUsedInStudio) {
			
			TextureRegion[] rets = new TextureRegion[3];
			TextureRegion region = new TextureRegion(regions[imageId], x, y, w,h);

			rets[0] = rets[1] = rets[2] = region;
			return rets;
		}

		@Override
		public TextureRegion[] loadImage(String spriteName, int imageId,int orientationUsedInStudio) {
			return null;
		}

	}
}
